home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Your Choice 1
/
your choice.zip
/
your choice
/
OS2
/
AM4PM
/
RING.AMC
< prev
Wrap
Text File
|
1993-07-14
|
6KB
|
236 lines
/*********************************************************************/
/* RING.AMC - Make something when it rings */
/* *//* This program is called by AM4PM.EXE. */
/* *//* Input: arg(1) The string from DCE resulting in this call */
/* Input: arg(2) Number of rings so far */
/* *//* Output: 0 Normal. Only AT+VLS=0 is done before waiting */
/* 1 Full init. Reinit COM-port and everything. */
/* 2 Terminate AM4PM. */
/* *//*********************************************************************/
PlayBackCode='123' /* Code for playing back messages */
ModemCode='secret' /* Code for accessing OS2YOU */
CALL AMDPrint 'RING.AMC('arg(1)', 'arg(2)') started'
CALL AMSetLastEventText arg(1)
if \ (arg(1) = 'VCON') then
do
/* Answer in fewer rings if there are messages waiting */
if vAMMsgs = 0 then rings=vAMRings
else rings=vAMRings-1
if arg(2) < rings then return 0
end
CALL AMSetStateText 'Playing greeting message'
AMSendW('AT+VLS=2')
DLECode=AMPlayFile('GREETING.ZVD')
select
when DLECode='*' then
return ReadCmd()
when DLECode='c' | DLECode='#' then
return StartFax()
when DLECode='5' then
return StartModem()
when DLECode='b' then
do
CALL AMSetLastEventText 'Busy'
return 0
end
when DLECode='!' then
return 0;
otherwise
nop
end
AMSendW('AT+VTS=[800,0,12]')
CALL AMSetStateText 'Recording message'
CrntMFile=AMOpenRecFile()
CALL AMStartRec(1) /* 1 = CELP, 2 = ADPCM2, 3 = ADPCM3 */
DLECode=AMWaitDLECode()
CALL AMEndRec
CALL AMCloseRecFile
/* DLECode = 'q' */
select
when DLECode='c' | DLECode='#' then
do
'del' CrntMFile
return StartFax()
end
when DLECode='5' | DLECode='s' then
do
'del' CrntMFile
return StartModem()
end
when DLECode='b' then
do
'del' CrntMFile
CALL AMSetLastEventText 'Busy'
return 0
end
when DLECode='q' then
do
CALL AMSetLastEventText 'Message stored'
Descr='Put CID text here'
DescrEA='FDFF'X || d2c(length(Descr)) || '00'X || Descr
CALL SysPutEA CrntMfile, '.SUBJECT', DescrEA
return 0
end
when DLECode='*' then
return ReadCmd()
otherwise
nop
end
Exit 0
ReadCmd:
CALL AMSetStateText 'Waiting for command'
AMSendW('AT+VTS=[1600,0,5]')
CALL AMStartListenDLECode
UsrCmd=""
ContProcCmd=1
do while ContProcCmd
DLECode=AMWaitDLECode()
select
when DLECode='q' | DLECode='s' | DLECode='b' | DLECode='c' then
do
ContProcCmd=0
end
when DLECode='*' then
do
CALL AMEndListenDLECode
AMSendW('AT+VTS=[1600,0,5]')
CALL AMStartListenDLECode
UsrCmd=""
end
when DLECode='#' then
do
CALL AMEndListenDLECode
CALL ProcCmd UsrCmd
CALL AMStartListenDLECode
UsrCmd=""
end
when DLECode >= 0 & DLECode <= 9 then
UsrCmd = UsrCmd""DLECode
otherwise
nop
end
end
CALL AMEndListenDLECode
return 0
ProcCmd: arg UsrCmd
CALL AMDPrint 'UsrCmd' UsrCmd
select
when UsrCmd=PlayBackCode then
CALL PlayAllFiles
otherwise
AMSendW('AT+VTS=[400,0,10]')
end
return 0
PlayAllFiles:
CALL AMSetStateText 'Playing back messages'
CALL AMSetLastEventText 'Playback'
AMPlayFile('GREET2.ZVD')
CALL SysFileTree 'M*.ZVD', 'file.', 'FO'
if file.0 = 0 then
do
AMPlayFile('NOMSG.ZVD') /* There are no messages */
return 0
end
AMPlayFile('SOMEMSGS.ZVD') /* Here comes the messages */
do i=1 to file.0
DLECode=AMPlayFile(file.i)
if \ (DLECode='1' | DLECode='2' | DLECode='3') then
do
CALL AMStartListenDLECode
DLECode=AMWaitDLECode()
CALL AMEndListenDLECode
end
select
when DLECode='2' then
do
'del' file.i
AMPlayFile('DELMSG.ZVD') /* Message deleted */
end
when DLECode='3' then
i=i-1
otherwise
nop
end
end
AMPlayFile('ENDMSGS.ZVD') /* That was all messages */
return 0
StartFax:
CALL AMDPrint 'Fax detected'
CALL AMSetStateText 'Waiting for fax'
AMSendW('AT&D0') /* Let the connection be open even if the port is closed */
AMCloseComm()
AMStartProg('FxRcv -cc')
CALL AMSetLastEventText 'FxRcv -cc started'
SysSleep(15) /* Give FaxWorks a chance to open the port */
/* AM4PM will try to open the port again */
return 1
StartModem:
CALL AMDPrint 'Looking for modem'
CALL AMSetStateText 'Looking for modem'
AMSendW('AT+FCLASS=0')
ResCode=AMSendW('ATA')
select
when ResCode='NO CARRIER' then
return 1
otherwise
do
CALL AMSetLastEventText 'Modem detected'
pw=AMSendW('Enter password+(ctrl-j)')
if pw=ModemCode then
do
CALL AMSetLastEventText 'OS2YOU started'
HotComm=AMGetHotComm()
ResCode=AMStartProg('Os2You -l' HotComm '-i 300 -f 100 -e cmd.exe')
CALL AMDPrint 'Os2You returned' ResCode
CALL AMReleaseHotComm
end
return 1
end
end
return 0